/*
 * @Date: 2022-11-05 11:33:03
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-11-24 10:11:00
 * @FilePath: \vue-admin-ts\src\store\index.ts
 * @Description: vuex
 */
import { createStore, Store, useStore as useNewStore } from "vuex";
import loginModule from "./login";
import systemModule from "./main/system";
import type { IRootWithModule } from "./type";
const store = createStore({
  state: () => {},
  actions: {},
  mutations: {},
  getters: {},
  modules: {
    loginModule,
    systemModule,
  },
  // plugins: [
  //   //持久化
  //   createPersistedState({
  //     storage: window.sessionStorage,
  //   }),
  // ],
});
export const setUpStore = () => {
  store.dispatch("loginModule/loadLocalState");
};
export function useStore(): Store<IRootWithModule> {
  return useNewStore();
}
export default store;
